package com.yanqu.road.logic.activity.foxcard.game.label;

import com.yanqu.road.entity.activity.foxcard.FoxSaleCard;
import com.yanqu.road.entity.activity.foxcard.config.FoxCardEffectCardConfig;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardCouponType;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardType;
import com.yanqu.road.utils.RandomHelper;

import java.util.List;

/**
 * 持有该标签进入商店时，必然会出现一张{0}品质小丑牌。
 */
public class FoxCardLabel1 extends FoxCardLabelBase {
    @Override
    protected int labelHandle(FoxCardGameLogic gameLogic) {
        if (triggerType != eFoxCardTriggerType.NEW_SALE_CARD) {
            return 0;
        }
        int saleCardNum = gameLogic.getShopSaleCardNum();
        if (saleCardNum <= 0) {
            return 0;
        }

        int cardQuality = labelConfig.getParamList().get(0);
        List<FoxSaleCard> foxSaleCards = gameLogic.getConfig().randomEffectCard(gameLogic.getGameData().getEffectCards(), cardQuality, 1, -1, gameLogic.getCouponAddValue(eFoxCardCouponType.COUPON8.getValue()));

        if (foxSaleCards.isEmpty()) {
            return 0;
        }

        FoxSaleCard saleCard = foxSaleCards.get(0);
        saleCard.setId(gameLogic.getGameData().generalCardUniqueId());

        gameLogic.addShopSaleCard(saleCard);
        return 1;
    }
}
